home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 283_01 / wbox.c < prev    next >
C/C++ Source or Header  |  1988-12-08  |  3KB  |  111 lines

  1. /* wbox.c -- 9/5/88, d.c.oshel
  2.    */
  3.  
  4. #include "vidinit.h"
  5.  
  6.  
  7. /*======================*/
  8. /* WindowBox            */
  9. /*======================*/
  10.  
  11. /* this version draws even the largest box almost instantaneously
  12. ** dco, 8/29/86
  13. */
  14.  
  15. void windowbox( int tx, int ty, int bx, int by )
  16. {
  17.         extern int ScrollAttributeFlag;  /* in scroll.c */
  18.  
  19.         static int i,j; 
  20.         static int temp;
  21.  
  22.         if (!Initialized) vid_init(0);
  23.  
  24.         ScrollAttributeFlag = vid_attr + 1;
  25.  
  26.         /* first, clear the working area to startle and amuse...
  27.         */
  28.  
  29.         setwindow( tx, ty, bx, by );
  30.         clrwindow();
  31.  
  32.         /* now, draw a crisp double-lined box (user's vid_attr ignored)
  33.         */
  34.  
  35.         temp = vid_attr;
  36.  
  37.         /* unfortunately, this draws an invisible box with CGA card and b&w crt
  38.         vid_attr = (video.mode == 2)? vid[15]: vid[10];
  39.         */
  40.         vid_attr = (video.mode == 7)? vid[10]: vid[15];
  41.         
  42.         tx = lm; /* use values that setwindow range checking may have found! */
  43.         ty = tm;
  44.         bx = rm;
  45.         by = bm;
  46.  
  47.         /* then, draw the border AROUND the area!
  48.         */
  49.  
  50.         fullscreen();        /* allows gotoxy to use the argument dimensions */
  51.  
  52.         if (tx > TOPX) { --tx; }
  53.         if (ty > TOPY) { --ty; }
  54.         if (bx < BTMX) { ++bx; }
  55.         if (by < BTMY) { ++by; }
  56.  
  57.         /* top line
  58.         */
  59.         gotoxy( tx, ty );
  60.         rptchar('═',bx - tx);
  61.  
  62.         /* right side
  63.         */
  64.         gotoxy( bx, ty );
  65.         rptchar('╗',1);
  66.  
  67.         j = by - ty;       /* put the for loop condition into a static int */
  68.         for ( i = 1; i < j; i++ )
  69.         {
  70.              gotoxy( bx, ty + i);
  71.              rptchar('║',1);
  72.         }
  73.  
  74.         /* bottom line 
  75.         */
  76.         gotoxy( bx, by );
  77.         rptchar('╝',1);
  78.  
  79.         gotoxy( tx, by );
  80.         rptchar('═',bx - tx);
  81.         rptchar('╚',1);
  82.  
  83.         /* left side
  84.         */
  85.         for ( i = 1; i < j; i++ )
  86.         {
  87.              gotoxy( tx, ty + i);
  88.              rptchar('║',1);
  89.         }
  90.  
  91.         gotoxy(tx,ty);
  92.         rptchar('╔',1);
  93.  
  94.         /* last, restore entry dimensions, with fixups on squashed margins
  95.         */
  96.  
  97.         /* Box is AROUND window    Window is squashed onto box's outline */
  98.         /* ---------------------   ------------------------------------- */
  99.            ++tx;                   /* else tx always was TOPX, so tx++;  */
  100.            ++ty;                   /* else ty always was TOPY, so ty++;  */
  101.            --bx;                   /* else bx always was BTMX, so bx--;  */
  102.            --by;                   /* else by always was BTMY, so by--;  */
  103.  
  104.         setwindow( tx, ty, bx, by );
  105.         gotoxy(0,0);
  106.         vid_attr = temp;  /* restore user's vid_attr */
  107. }
  108.  
  109.  
  110.  
  111.